<!DOCTYPE html>
<html>

	<head>
		<meta charset="utf-8">
		<meta http-equiv="X-UA-Compatible" content="IE=edge">
		<title>GT pro钱包</title>
		<meta content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no" name="viewport">
		<link rel="stylesheet" href="bower_components/bootstrap/dist/css/bootstrap.min.css">
		<link rel="stylesheet" href="bower_components/font-awesome/css/font-awesome.min.css">
		<link rel="stylesheet" href="bower_components/Ionicons/css/ionicons.min.css">
		<link rel="stylesheet" href="bower_components/datatables.net-bs/css/dataTables.bootstrap.min.css">
		<link rel="stylesheet" href="dist/css/AdminLTE.min.css">
		<link rel="stylesheet" href="dist/css/skins/skin-blue.min.css">
		<link rel="stylesheet" href="css/style.css">
		<link rel="stylesheet" href="css/card.css">
		<link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Source+Sans+Pro:300,400,600,700,300italic,400italic,600italic">

		<link rel="stylesheet" href="bower_components/bootstrap-daterangepicker/daterangepicker.css">
		<link rel="stylesheet" href="bower_components/bootstrap-datepicker/dist/css/bootstrap-datepicker.min.css">
	</head>

	<body class="hold-transition skin-blue sidebar-mini">
		<div class="wrapper">
			<div class="content-wrapper">
				<section class="content-header">
					<ol class="breadcrumb">
						<li>
							<a href="#"><i class="fa fa-dashboard"></i>系统设置</a>
						</li>
						<li class="active">推送记录</li>
					</ol>
				</section>
				<section class="content">
					<div class="box">
						<div class="box-header with-border">
							推送记录
						</div>
						<div class="box-body">
							<div class="buyu_search_group">
								<div class="row" style="margin-bottom:10px;">
									<div class="col-xs-12">
										<div class="fixed-table-toolbar margin">
											<div class="bs-bars pull-left">
												<div class="hidden-xs" id="managerTableToolbar" role="group">
													<button type="button" class="btn btn-primary " onclick="addPush()" id=""><i class="fa fa-plus"></i>&nbsp;新增</button>
												</div>
											</div>
										</div>
									</div>
								</div>
							</div>
						</div>
						<div class="row">
							<div class="col-xs-12">
								<!-- /.box-header -->
								<div class="box-body">
									<table id="example" class="display nowrap table table-bordered table-striped" style="width:100%;">
										<thead>
											<tr>
												<th>序号</th>
												<th>用户Id</th>
												<th>链接</th>
												<th>标题</th>
												<th>内容</th>
												<th>添加时间</th>
											</tr>
										</thead>
										<tbody></tbody>
									</table>
								</div>
							</div>
						</div>
					</div>
				</section>
			</div>
		</div>
		<div class="modal fade parents in" id="addPushModal">
			<div class="modal-dialog">
				<div class="modal-content">
					<div class="modal-header"> <button type="button" class="close" data-dismiss="modal" aria-label="Close">	                  				<span aria-hidden="true">×</span>								</button>
						<h4 class="modal-title">添加推送</h4> </div>
					<div class="modal-body">
						<form class="form-horizontal">
							<div class="box-body">
								<label class="margin-bottom-none col-xs-12" style="width:100%;font-weight:normal;padding-left: 0;">
									用户id<span class="text-danger">(不传则推送所有)</span>
									<input type="text" class="form-control" name="users"/>
								</label>

								<label class="margin-bottom-none col-xs-12" style="width:100%;font-weight:normal;padding-left: 0;">
									跳转的h5
									<input type="text" class="form-control" name="h5_url">
								</label>
								<label class="margin-bottom-none col-xs-12" style="width:100%;font-weight:normal;padding-left: 0;">
									标题
									<input type="text" class="form-control" name="title">
								</label>
								
								<label class="margin-bottom-none col-xs-12" style="width:100%;font-weight:normal;padding-left: 0;">
									内容
									<input type="text" class="form-control" name="msg">
								</label>
							</div>
						</form>
					</div>
					<div class="modal-footer"> <button type="button" class="btn btn-primary save" onclick="addPushSave()">确定</button> </div>
				</div>
			</div>
		</div>
		<script src="bower_components/jquery/dist/jquery.min.js"></script>
		<script src="bower_components/bootstrap/dist/js/bootstrap.min.js"></script>
		<script src="bower_components/datatables.net/js/jquery.dataTables.min.js"></script>
		<script src="bower_components/datatables.net-bs/js/dataTables.bootstrap.min.js"></script>

		<script src="bower_components/bootstrap-datepicker/dist/js/bootstrap-datepicker.min.js"></script>
		<script src="bower_components/moment/min/moment.min.js"></script>
		<script src="bower_components/bootstrap-daterangepicker/daterangepicker.js"></script>
		<script src="dist/js/adminlte.min.js"></script>
		<script src="js/argument.js"></script>
		<script src="js/fun.js"></script>
		<script src="js/nav.js"></script>
		<script src="js/pop.js"></script>
		<script type="text/javascript">
			$('#select_time').daterangepicker({
				timePicker: true,
				timePicker24Hour: true,
				autoUpdateInput: false,
				locale: {
					format: "YYYY-MM-DD HH:mm"
				}
			})

			var table = $('#example').DataTable({
				'ordering': false,
				'lengthChange': false,
				'searching': false,
				'info': true,
				"processing": true,
				"serverSide": true,
				'scrollX':true,
				"ajax": {
					"type": 'post',
					"url": url + "Back_PushHistory",
					"contentType": "application/x-www-form-urlencoded",
					"headers": {
						"auth-token": localStorage.getItem("wallet_token")
					},
					"data": function(d) {
						var Json = {} //renderData(dataType);
						Json.page_num = d.start / 10 + 1;
						var data = {};
						data.data = JSON.stringify(Json);
						return data;
					},
					"dataFilter": function(data) {
						var datajson = eval('(' + data + ')');
						if(datajson.status == 1000||datajson.status == 102) {
							ToLogin(datajson)
							return false;
						} else if(datajson.status != 1) {
							alert(datajson.error);
							return false;
						}
						var json = {};
						if(datajson.data == null) {
							json.recordsTotal = 0;
							json.recordsFiltered = 0;
							json.data = [];
							return JSON.stringify(json);
						} else {
							json.recordsTotal = datajson.data.total;
							json.recordsFiltered = datajson.data.total;
							json.data = datajson.data.data_list;
							return JSON.stringify(json);
						}
					}
				},
				"columns": [{
						data: 'id'
					},
					{
						data:null,render:function(data){
							var str = ''
							console.log(data.receive);
							return data.receive
						} //'receive'
					},
					{
						data: 'h5_url'
					},
					{
						data: 'title'
					},
					{
						data: null,render:function(data){
							return '<div class="toolong" title="'+data.content+'" style="width:300px;">'+data.content+'</div>'
						}//'content'
					},
					{
						data: 'add_time'
					},
				]
			})
		</script>
		<script>
			function addPush() {
				$("#addPushModal").modal('show');
			}
			
			function addPushSave(){
				$.ajax({
					'type': 'post',
					'url': url + "Back_SendPush",
					'headers': {
						'auth-token': localStorage.getItem("wallet_token")
					},
					'contentType': "application/x-www-form-urlencoded",
					'data': {
						data:JSON.stringify({
							msg:$("#addPushModal [name = msg]").val(),
							users:$("#addPushModal [name = users]").val(),
							title:$("#addPushModal [name = title]").val(),
							h5_url:$("#addPushModal [name = h5_url]").val(),
						})
					},
					'success': function(res) {
						if(res.status == 1000||res.status == 102) {
							ToLogin(res)
							return false;
						} else if(res.status != 1) {
							alert(res.error);
							return false;
						}
						$("#addPushModal").modal("hide");
						$("#addPushModal input").val('');
						move("success", res.error);
						table.draw(false);
					}
				})
			}
		</script>
	</body>

</html>